home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.3 KB | 97 lines | [TEXT/CWIE] |
- // MenuItem.h
-
- #ifndef MenuItem_h
- #define MenuItem_h
-
- #ifndef Integers_h
- #include "Integers.h"
- #endif
- #ifndef MenuID_h
- #include "MenuID.h"
- #endif
- #ifndef Str_h
- #include "Str.h"
- #endif
-
- class MenuItem
- {
- private:
- MenuHandle menu;
- uint16 item;
-
- enum SpecialEffect
- {
- noEffect = 0,
- submenu = 0x1b,
- script = 0x1c,
- reducedIcon = 0x1d,
- smallIcon = 0x1e,
- commandKey = 0x21
- };
-
- SpecialEffect Effect() const;
-
- bool CanSetEffect( SpecialEffect ) const;
- bool CanClearEffect( SpecialEffect ) const;
- bool CanSetCommandKey() const;
-
- void SetEffect( SpecialEffect );
- void ClearEffect( SpecialEffect );
-
- public:
- MenuItem( MenuHandle theMenu, uint16 theItem )
- : menu( theMenu ),
- item( theItem )
- {}
-
- bool CanEnableIndividually() const { return item < 31; }
- bool Enabled() const;
- void Enable();
- void Disable();
- void SetEnabled( bool );
-
- void GetText( String255& string ) const { GetMenuItemText( menu, item, string ); }
- void SetText( ConstPString string );
- void BeDivider() { SetMenuItemText( menu, item, "\p-" ); }
-
- ::Style Style() const;
- void SetStyle( ::Style style ) { SetItemStyle( menu, item, style ); }
-
- uint8 HasMark() const { return Mark() != 0; }
- uint8 Mark() const;
- void SetMark( uint8 );
- void RemoveMark() { SetMark( noMark ); }
- void Check() { SetMark( checkMark ); }
- void PartialCheck() { SetMark( '-' ); }
-
- bool HasCommandKey() const { return Effect() == commandKey; }
- uint8 CommandKey() const;
- void SetCommandKey( uint8 );
- void RemoveCommandKey();
-
- bool HasSubmenu() const { return Effect() == submenu; }
- MenuID Submenu() const;
- void SetSubmenu( MenuID );
- void RemoveSubmenu();
-
- bool HasScriptCode() const { return Effect() == script; }
- uint8 ScriptCode() const;
- void SetScriptCode( uint8 );
- void RemoveScriptCode();
-
- bool HasIcon() const;
- int16 Icon() const;
- void SetIcon( int16 resource );
- void RemoveIcon();
-
- bool ReducesIcon() const { return Effect() == reducedIcon; }
- void ReduceIcon() { SetEffect( reducedIcon ); }
- void DontReduceIcon() { ClearEffect( reducedIcon ); }
-
- bool UsesSmallIcon() const { return Effect() == smallIcon; }
- void UseSmallIcon() { SetEffect( smallIcon ); }
- void DontUseSmallIcon() { ClearEffect( smallIcon ); }
- };
-
- #endif
-